<?php
	$path_one = 'admin/admin_project';
	$path_two = 'admin/admin_project_manage';
	$filename = 'admin/project_device_list';
	require_once("header.php");
	require_once("admin_comm.php");
	require_once $_site->get_handlepath('project');
	$page=request('page',false,true,false,1);
	$pagesize=request('pagesize',false,true,false,10);
	$admin_id = '';
	if($cookie['group'] != 6){
		$admin_id = $cookie['id'];
	}
	$project_list = project_fun_get_project_list(array('uid'=>$admin_id),false,false);
	if($project_list){
		$pids = array();
		foreach($project_list as $k => $v){
			$pids[$k] = $v['id'];
		}
		$pidstr = implode(',',$pids);
	}else{
		location_msg('没有项目','/admin/admin_project_list');
	}
	$pid = request('pid',false,true);
	if($pid && in_array($pid,$pids)){
		$data['pid'] = $pid;
		$section_pid[$pid] = 'selected';
	}else{
		$data['pid'] = $pidstr;
	}
	$data['state']=$state=request('state',false,true,false,0);
	$result = project_fun_get_project_device_list($data,$page,$pagesize);
	$hover[$data['state']]=' class="hover" ';
?>
<script type="text/javascript" charset="utf-8">

	loader.file({
		plugin:['validform/main','dialog/main'],
		skincss:['list']
	})
	
	function get_project_info (){
		dialog.iframe({
			title:'项目选择',
			is_resize:false,
			top:{
				is_show:true,
				btn_max:false,
				btn_min:false,
				btn_close:true,
				height:33,
				is_move:true
			},
			is_scroll:false,
			min_width:350,
			min_height:500,
			is_center:true,
			is_lock_back:false,
			content:'/admin/common_choise?callback=set_project_info&parm=uid.<?php echo $admin_id?>,',
			name:'choise_project'
		});
	}
	
	function set_project_info(id,title){
		if(id && title){
			$("#pid").val(id);
			$("#name_title").val(title);
		}
	}

</script>
</head>
<body>
	<div class="position_nav">你所在的当前位置：<?php echo $path_str;?></div>
		<div class="main">
			<div class="sos_box">
				<form action="" method="post" id="form1">
				选择项目：<input type="text" id="name_title">
				          <input type="hidden" name="pid" id="pid" value="<?php echo $pid ?>">
						  <input type="hidden" name="state" value="<?php echo $state ?>">
						  <input type="submit" class="button1" value="搜索">
				</form>
			</div>
			<div class="power_nav">
				<ul>
					<li <?php echo $hover[0] ;?>>
						<a href="/admin/project_device_list?state=0&<?php echo preg_replace('/(&page=\d*)|(&state=\d*)|(&v=\w+\/\w+)/','',$_SERVER['QUERY_STRING']) ;?>">全部</a>
					</li>
					<li <?php echo $hover[1] ;?>>
						<a href="/admin/project_device_list?state=1&<?php echo preg_replace('/(&page=\d*)|(&state=\d*)|(&v=\w+\/\w+)/','',$_SERVER['QUERY_STRING']) ;?>">绑定</a>
					</li>
					<li<?php echo $hover[2] ;?>>
						<a href="/admin/project_device_list?state=2&<?php echo preg_replace('/(&page=\d*)|(&state=\d*)|(&v=\w+\/\w+)/','',$_SERVER['QUERY_STRING']) ;?>">已解绑</a>
					</li>
				</ul>
			</div>
			<table cellpadding="0" cellspacing="1" border="0" class="table">
				<tr>
					<th width="10%" align="center">序号</th>
					<th width="10%" align="left">项目</th>
					<th width="20%" align="center">设备号</th>
					<th width="20%" align="center">绑定状态</th>
					<th width="15%" align="center">添加时间</th>
				</tr>
				<?php
					if($result['rows']){
						foreach ($result['rows'] as $v){
							?>
							<tr>
								<td align="center"><?php echo $v['id'] ;?></td>
								<td align="left"><?php echo $v['title'] ;?></td>
								<td align="center"><?php echo $v['no'] ;?></td>
								<td align="center"><?php echo $v['state']==1?'绑定':"已解绑" ;?></td>
								<td align="center"><?php echo date('Y-m-d H:i',$v['time']) ;?></td>
					</tr>
							<?php
						}
					}else{
						?>
						<tr>
							<td colspan="5">没有设备信息！</td>
						</tr>
						<?php
					}
				?>
				<tr>
					<td colspan="5">
						<div class="list_more">
							设备总数：<?php echo $result['row_count']?$result['row_count']:0 ;?>
							<?php
								echo page_method($result['row_count'], $page, $result['page_count'], 10, '?'.preg_replace('/(&page=\d*)/','',$_SERVER['QUERY_STRING']), false);
							?>
						</div>
					</td>
				</tr>
			</table
		></div>
	</div>
</body>
</html>


